﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Scripting.Hosting;
using IronPython.Hosting;
using System.Reflection;
using ScriptEngine.Interface;

namespace ScriptEngine
{
    public class ScriptCache : IScriptCache
    {
        private Dictionary<string, CompiledCode> _Scripts;
        
        public CompiledCode this[string script]
        {
            get
            {
                if (_Scripts.ContainsKey(script))
                {
                    return _Scripts[script];
                }
                else
                {
                    return null;
                }
            }

            set
            {
                if (!_Scripts.ContainsKey(script))
                    _Scripts.Add(script, value);
                else
                    _Scripts[script] = value;
            }
        }

        public ScriptCache()
        {
            _Scripts = new Dictionary<string, CompiledCode>();
        }
    }
}
